<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@include file="/common/definition.jsp"%>
<%@ page language="java" import="java.util.*"%>
<html:html>
<tiles:insert beanName="shop-definition" flush="true">
	<tiles:put name="title"> Welcome </tiles:put>
	<tiles:put name="body" type="string">

		<div class="col-md-10">
		<div class="cole-md-12 mainHome" style="padding: 20px; min-height: 550px">
			<table id="Result"
				class="table table-striped table-hover table-borderall table-condensed m-melanin-datatable">
				<thead>
					<tr>
						<th class="col-md-1"><font size="2">Hình ảnh</font></th>
						<th class="col-md-3"><font size="2">Tên sản phẩm</font></th>
						<th class="col-md-2"><font size="2">Giá niêm yết</font></th>
						<th class="col-md-2"><font size="2">Giá khuyến mãi</font></th>
						<th class="col-md-1"><font size="2">Quản lý</font>
						</th>

					</tr>
				</thead>
				<tbody>
					<s:iterator value="productModel.listProduct">
						<tr>
							<td class="col-md-1">
								<s:a action="detailShopProduct">
									<s:if test="mainImgLink == null">
										<img style="height: 70px" width=100% src='img/avatar/no_product_img.jpg'>
									</s:if> <s:else>
										<img style="height: 70px" width=100% src='<s:property value="mainImgLink"/>'>
									</s:else>
									<s:param name="listID"><s:property value="listID" /></s:param>
								</s:a>
							</td>
							<td class="col-md-7">
								<s:a action="detailShopProduct"><s:property value="catName" /> 
								<s:property value="brandName" /> <s:property value="productName" />
								<s:param name="listID"><s:property value="listID" /></s:param></s:a>
							</td>
							<td class="col-md-2"><p class="text-success"><s:property value="sellingPrice" />000 VND</p></td>
							<td class="col-md-2">
								<s:if test="discount != null"><p class="text-success">
									<s:property value="discount"/>000 VND (<s:property value="discountPercent"/> %)</p>
								</s:if>
								<s:else>
									Hiện không có khuyến mại
								</s:else>
							</td>
							<td class="col-md-1"><div class="btn-group">
									<button type="button" class="btn btn-default dropdown-toggle"
										data-toggle="dropdown">
										Action <span class="caret"></span>
									</button>
									<ul class="dropdown-menu">
										<li><s:a action="productInfoMng-Page">Thông tin<s:param
													name="productID">
													<s:property value="productID" />
												</s:param>
											</s:a></li>
										<li><s:a action="imageManage-page">Hình ảnh<s:param
													name="productID">
													<s:property value="productID" />
												</s:param>
											</s:a></li>
										<li>
											<s:if test="discount == null">
												<s:a action="makeDiscount-page">Giảm giá sản phẩm
												<s:param name="productID"> <s:property value="productID" /> </s:param>
												</s:a>
											</s:if>
											<s:else>
												<s:a action="editDiscount-page">Chỉnh sửa khuyến mại
												<s:param name="productID"> <s:property value="productID" /> </s:param>
												</s:a>
											</s:else>
										</li>
										<s:if test="discount != null">
											<li>
												<s:a action="endDiscount">Ngừng khuyến mại
												<s:param name="productID"> <s:property value="productID" /> </s:param>
												</s:a>
											</li>
										</s:if>
										<li><s:a action="endList">Ngưng bán
											<s:param name="productID">
												<s:property value="productID" />
											</s:param>
										</s:a></li>
									</ul>
								</div></td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
			</div>
		</div>
		<script type="text/javascript" src="js/jquery.dataTables.js"></script>
		<script src="js/datatables.js"></script>
		<script type="text/javascript">
			$(document)
					.ready(
							function() {
								$('#Result')
										.dataTable(
												{
													"sPaginationType" : "bs_full",
													"oLanguage" : {
														"sSearch" : "",
														"sZeroRecords" : "Không có dữ liệu",
														"sEmptyTable" : "Không có dữ liệu",
														"sInfo" : "Hiển thị từ _START_ đến _END_. Tổng cộng: _TOTAL_ dòng.",
														"sInfoFiltered" : "",
														"sLengthMenu" : "Hiển thị _MENU_ Dòng",
														"sInfoEmpty" : 'Không tìm thấy dữ liệu.'
													}
												});
								$('#Result')
										.each(
												function() {
													var datatable = $(this);
													// SEARCH - Add the placeholder for Search and Turn this into in-line form control
													var search_input = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_filter] input');
													search_input.attr(
															'placeholder',
															'Tìm Nhanh');
													search_input
															.addClass('form-control input-sm');
													// LENGTH - Inline-Form control
													var length_sel = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_length] select');
													length_sel
															.addClass('form-control input-sm');
												});
							});
		</script>

	</tiles:put>
</tiles:insert>
</html:html>
